home *** CD-ROM | disk | FTP | other *** search
- Path: news.belwue.de!uzwil!kuehl
- From: kuehl@uzwil.informatik.uni-konstanz.de (Dietmar Kuehl)
- Newsgroups: comp.lang.c++
- Subject: Re: Optimizing lists etc
- Date: 16 Apr 1996 12:02:12 GMT
- Organization: FakultΣt fⁿr Mathematik und Informatik
- Message-ID: <4l0284$bua@news.BelWue.DE>
- References: <Dpn9xH.47v.0.-s@cs.vu.nl>
- Reply-To: dietmar.kuehl@uni-konstanz.de
- NNTP-Posting-Host: uzwil.informatik.uni-konstanz.de
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hi,
- Oscar Scholten (oscholt@cs.vu.nl) wrote:
- : Yet I was wondering if it is worth it to optimize them. Right now
- : the structures are pretty streight-forward, they all have some
- : search and sort options. The structures could become very large,
- : and we do not want to waste any cpu-time on them.
-
- Do optimization when it turns out that optimization is necessary.
- Locate the portions which need optimization by profiling not by one of
- the more common methods like "guessing", "knowning off-hand", "seeing",
- etc. If you have located one (of the normally few) portions of code,
- you might do optimizations there like hoisting checks out of loops,
- using better suited algorithms or data structures (e.g. an array might
- be better suited than a dynamically allocated list), inlining crucial
- functions, turning tail recursion into iteration etc. Get not be
- tempted to try optimizations by writing them in assembler: Most
- compilers are better in writing assembler code than most humans are.
- Although it is somewhat platform dependent, it is likely that you would
- end up with slower code if you write them in assembler yourself. There
- are only very few cases where assembler really pays off: If you are
- doing very fancy bitmanipulations which are directly supported by the
- assembler, there might be a speed gain which justifies writing
- assembler. Note, however, that assembler code is inherently harder to
- maintain or port to new platfroms.
-
- : So is it possible to optimize a template using inline assembly etc ?
-
- It probably is portable but it will be very compiler dependent and the
- necessary assembler might have to change with the next compiler
- release.
-
- : And more important, what is the speed gain ?
-
- On a newer architecture, i.e. a RISC cpu, you are good if your
- assembler is nearly as fast as the code generated by a compiler with
- optimization turned on...
- --
- dietmar.kuehl@uni-konstanz.de
- http://www.informatik.uni-konstanz.de/~kuehl/
- I am a realistic optimist - that's why I appear to be slightly pessimistic
-